/**
 * 
 */
package com.episode6;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class UserCountListener implements HttpSessionListener {
	
	private CounterBean counter = new CounterBean();

	@Override
	public void sessionCreated(HttpSessionEvent event) {
		this.counter.increase();
		event.getSession().setAttribute("user-count", this.counter);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent event) {
		this.counter.decrease();
	}
}
